package 多线程.案例.myTimer;

public class MyTask implements Comparable<MyTask> {
    private Runnable command;
    private long time;

    public MyTask(Runnable command, long after) {
        this.command = command;
        this.time = System.currentTimeMillis() + after;
    }

    public long getTime() {
        return time;
    }

    //执行任务
    public void run() {
        command.run();
    }

    @Override
    public int compareTo(MyTask o) {
        return (int) (this.time - o.getTime());
    }
}